package com.nvshen.zhangmeiying;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.Toast;
import com.umeng.analytics.MobclickAgent;

/**
 * Created by wxc on 14-8-4.
 */
public class BaseActivity extends Activity
{
    protected LayoutInflater inflater;

//    protected IWeiboShareAPI weibo;
//    protected SsoHandler ssoHandler;
//    protected WeiboAuth mWeiboAuth;
//    protected Tencent mTencent;


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        initWaitingDialog();

        inflater = LayoutInflater.from(this);

        getWindow().setFormat(PixelFormat.TRANSLUCENT);

//        mTencent = Tencent.createInstance(QQManager.APP_ID, this);
//        weibo = WeiboShareSDK.createWeiboAPI(this, SinaManager.APP_KEY);
//        mWeiboAuth = new WeiboAuth(this, SinaManager.APP_KEY, SinaManager.REDIRECT_URL, SinaManager.SCOPE);
//        ssoHandler = new SsoHandler(this, mWeiboAuth);

    }

    public void goToActivity(Class activityClass)
    {
        Intent intent = new Intent(this, activityClass);
        startActivity(intent);
    }

    protected ProgressDialog waitingDialog;

    private void initWaitingDialog()
    {
        waitingDialog = new ProgressDialog(this);
        waitingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        waitingDialog.setMessage("请稍候");
        waitingDialog.setCancelable(false);
    }

    public void showShortToast(String content)
    {
        Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
    }

    public void openActivity(Class<?> openClass)
    {
        Intent intent = new Intent(this, openClass);
        startActivity(intent);
    }

    public Activity getContext()
    {
        return this;
    }

    protected void sendBroadCast(String action)
    {
        Intent intent = new Intent(action);
        sendBroadcast(intent);
    }

    @Override
    protected void onPause()
    {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onResume()
    {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
//        if (ssoHandler != null)
//        {
//            ssoHandler.authorizeCallBack(requestCode, resultCode, data);
//        }
    }
}
